package com.jackrain.nea.ext.permission;

import lombok.Data;

import java.io.Serializable;
import java.util.Collection;

/**
 * @author lzm
 * @date 2017-11-17
 * 菜单权限对象
 */
@Data
public class MenuPermissionModel implements Serializable {
    private static final long serialVersionUID = -2766317746785750059L;
    private Long id;
    private MenuType type;

    private Long groupid;
    private Long ad_menu_id;
    private String mask;
    private Integer permission;
    private String name;
    private String description;
    private Long ad_table_id;

    public static MenuPermissionModel union(MenuPermissionModel left, MenuPermissionModel right) {
        MenuPermissionModel result = new MenuPermissionModel();
        result.setId(-1L);      //复合型的model,没有id
        result.setGroupid(-1L); //复合型的model,没有groupId
        result.setAd_menu_id(left.getAd_menu_id());
        result.setName(left.getName());
        result.setDescription(left.getDescription());
        result.setAd_table_id(left.getAd_table_id());
        result.setMask(TableMaskHelper.union(left.getMask(), right.getMask()));
        result.setPermission(left.getPermission() | right.getPermission());
        return result;
    }
}
